//
//  HWJiaoyixuzhiViewController.m
//  HWanGame
//
//  Created by 陈道斌 on 2019/9/12.
//  Copyright © 2019 Chendaobin. All rights reserved.
//

#import "HWJiaoyixuzhiViewController.h"

@interface HWJiaoyixuzhiViewController ()
@property(strong,nonatomic) UIView *majixuzhiview;
@property(strong,nonatomic) UIView *chushouView;
@end

@implementation HWJiaoyixuzhiViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setupUI];
}

//账号交易须知
- (void) setupUI {
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"交易须知";
    self.navigationItem.title = [HWjianzhiduiObject keylocalization:@"交易须知"];
    
    
    
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, CF_NavHeight, kScreenW, 90)];
    imageView.image = [UIImage imageNamed:@"deal_bgajiaoyi"];
    
    [self.view addSubview:imageView];
    
    
    UILabel *label  = [[UILabel alloc]initWithFrame:CGRectMake(17, 0, kScreenW-17*2, 90)];
    label.numberOfLines = 0;
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"交易采用小号转移的方式，买入或卖出游戏角色，都不会影响您的平台账号正常使用。" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFang SC" size: 12],NSForegroundColorAttributeName: [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0]}];
    label.attributedText = string;
    [imageView  addSubview:label];
    
    
    
    
    UIView *majixuzhiview = [[UIView alloc]initWithFrame:CGRectMake(0, imageView.bottom,  kScreenW, 300)];
   // majixuzhiview.backgroundColor = [UIColor redColor];
    self.majixuzhiview = majixuzhiview;
    [self.view addSubview:majixuzhiview];

    [self  addjiaoyixixuView];
    
    
    self.chushouView = [[UIView alloc]initWithFrame:CGRectMake(0, majixuzhiview.bottom+10,  kScreenW, 300)];
   // self.chushouView.backgroundColor = [UIColor redColor];
    [self.view addSubview:self.chushouView];
    
    [self addmaijiaxuezhshouhu];
    
    
    
    
}

// 交易须知
- (void)addjiaoyixixuView {
    
    UILabel *label  = [[UILabel alloc]initWithFrame:CGRectMake(17, 10, kScreenW-17*2, 40)];
    label.numberOfLines = 0;
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"买家须知" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFang SC" size: 12],NSForegroundColorAttributeName: [UIColor colorWithRed:54/255.0 green:147/255.0 blue:253/255.0 alpha:1.0]}];
    label.attributedText = string;
    [self.majixuzhiview  addSubview:label];
    
    NSArray *arr = @[@"1.账号信息已通过我们官方审核，因时间变化造成排行榜，称号，显示道具到期等变化，不视为信息失实；",@"2.成功购买后角色直接转入您的账号，重新登录游戏即可进行查收并使用；",@"3.交易过程仅限角色转移，不存在平台账号交易或手机换绑行为，无需担心角色找回；",@"4.交易完成后，不支持退货；",@"5.如因商品信息不实或其他因素问题，可联系客服核实协商决。"];
    
     NSMutableArray  *arrH =  [[NSMutableArray alloc]init];
     for (int i = 0 ; i < arr.count; i++) {
       CGFloat h =  [self  calculateRowHeight:arr[i] fontSize:12];
       [arrH addObject:[NSString stringWithFormat:@"%f",h]];
         
         
     }

    for (int i = 0 ; i < arr.count; i++) {
        
        UILabel *label = [[UILabel alloc] init];
        label.numberOfLines = 0;
        label.font = [UIFont systemFontOfSize:12];
        label.text = arr[i];
        label.textColor = RGB(51, 51, 51);
        label.frame = CGRectMake(17, 0, kScreenW-17*2, 30);
        [self.majixuzhiview addSubview:label];
       
        if (i == 0) {
            CGFloat h0 = [arrH[0] floatValue];
           
             label.frame = CGRectMake(17, 50, kScreenW-17*2, h0);
         
             NSMutableAttributedString *atrtabl =  [WMUtil   attributedStringWithText:arr[i] withRangText:@"已通过我们官方审核" withColor:RGB(236, 11, 11) withFont:[UIFont systemFontOfSize:12]];
    
            
             label.attributedText = atrtabl;
            
            
            
            
        } else if (i == 1) {
            CGFloat h0 = [arrH[0] floatValue];
            CGFloat h1 = [arrH[1] floatValue];
            label.frame = CGRectMake(17,50+h0+i*10, kScreenW-17*2, h1);
            
        } else if (i == 2){
            
            CGFloat h0 = [arrH[0] floatValue];
            CGFloat h1 = [arrH[1] floatValue];
            CGFloat h2 = [arrH[2] floatValue];
            label.frame = CGRectMake(17,50+ h0+h1+i*10, kScreenW-17*2, h2);
            
            
        }  else if (i == 3){
            
            CGFloat h0 = [arrH[0] floatValue];
            CGFloat h1 = [arrH[1] floatValue];
            CGFloat h2 = [arrH[2] floatValue];
            CGFloat h3 = [arrH[3] floatValue];
            label.frame = CGRectMake(17,50+ h0+h1+h2+i*10, kScreenW-17*2, h3);
            
            NSMutableAttributedString *atrtabl =  [WMUtil   attributedStringWithText:arr[i] withRangText:@"4.交易完成后，不支持退货；" withColor:RGB(236, 11, 11) withFont:[UIFont systemFontOfSize:12]];
            label.attributedText = atrtabl;
            
        } else {
            
            CGFloat h0 = [arrH[0] floatValue];
            CGFloat h1 = [arrH[1] floatValue];
            CGFloat h2 = [arrH[2] floatValue];
            CGFloat h3 = [arrH[3] floatValue];
            CGFloat h4 = [arrH[4] floatValue];
            label.frame = CGRectMake(17, 50+h0+h1+h2+h3+i*10, kScreenW-17*2, h4);
            
            self.majixuzhiview.frame = CGRectMake(0, 90+CF_NavHeight, kScreenW, 50+h0+h1+h2+h3+h4+i*10);
            
            
        }
        self.majixuzhiview.backgroundColor = [UIColor whiteColor];
    
    }
    
    
    
    
    
    
    
}



// 添加卖家须知

- (void)addmaijiaxuezhshouhu {
    
    UILabel *label  = [[UILabel alloc]initWithFrame:CGRectMake(17, 10, kScreenW-17*2, 40)];
    label.numberOfLines = 0;
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"卖家须知" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFang SC" size: 12],NSForegroundColorAttributeName: [UIColor colorWithRed:54/255.0 green:147/255.0 blue:253/255.0 alpha:1.0]}];
    label.attributedText = string;
    [self.chushouView  addSubview:label];
    
    
    NSArray *arr = @[@"1.出售申请提交后，官方将冻结小号审核信息，该小号在该游戏中的角色都将移除，无法登陆；",@"2.审核小号信息需保证真实有效，若审核不通过，或者您下架商品，可重新登录小号；",@"3.一旦售出，无法找回小号；",@"4.售出将收取5%手续费（最低5元），月度会员只需收取4%手续费（最低4元），季度会员只需收取3%手续费，年度会员免手续费！剩余收益发送至您的钱包内。",@"5.商品售出后，买家3天内无投诉，收益可解冻提现。"];
    
    NSMutableArray  *arrH =  [[NSMutableArray alloc]init];
    for (int i = 0 ; i < arr.count; i++) {
        CGFloat h =  [self  calculateRowHeight:arr[i] fontSize:12];
        [arrH addObject:[NSString stringWithFormat:@"%f",h]];
        
        
    }
    
    for (int i = 0 ; i < arr.count; i++) {
        
        UILabel *label = [[UILabel alloc] init];
        label.numberOfLines = 0;
        label.font = [UIFont systemFontOfSize:12];
        label.text = arr[i];
        label.textColor = RGB(51, 51, 51);
        label.frame = CGRectMake(17, 0, kScreenW-17*2, 30);
        [self.chushouView addSubview:label];
        
        if (i == 0) {
            CGFloat h0 = [arrH[0] floatValue];
            
            label.frame = CGRectMake(17, 50, kScreenW-17*2, h0);
            
            
        } else if (i == 1) {
            CGFloat h0 = [arrH[0] floatValue];
            CGFloat h1 = [arrH[1] floatValue];
            label.frame = CGRectMake(17,50+h0+i*10, kScreenW-17*2, h1);
            
        } else if (i == 2){
            
            CGFloat h0 = [arrH[0] floatValue];
            CGFloat h1 = [arrH[1] floatValue];
            CGFloat h2 = [arrH[2] floatValue];
            label.frame = CGRectMake(17,50+ h0+h1+i*10, kScreenW-17*2, h2);
            
            
        }  else if (i == 3){
            
            CGFloat h0 = [arrH[0] floatValue];
            CGFloat h1 = [arrH[1] floatValue];
            CGFloat h2 = [arrH[2] floatValue];
            CGFloat h3 = [arrH[3] floatValue];
            label.frame = CGRectMake(17,50+ h0+h1+h2+i*10, kScreenW-17*2, h3);
            
            NSMutableAttributedString *atrtabl =  [WMUtil   attributedStringWithText:arr[i] withRangText:@"4.售出将收取5%手续费（最低5元）" withColor:RGB(236, 11, 11) withFont:[UIFont systemFontOfSize:12]];
            
            label.attributedText = atrtabl;
            
            
        } else {
            
            CGFloat h0 = [arrH[0] floatValue];
            CGFloat h1 = [arrH[1] floatValue];
            CGFloat h2 = [arrH[2] floatValue];
            CGFloat h3 = [arrH[3] floatValue];
            CGFloat h4 = [arrH[4] floatValue];
            label.frame = CGRectMake(17, 50+h0+h1+h2+h3+i*10, kScreenW-17*2, h4);
            NSMutableAttributedString *atrtabl =  [WMUtil   attributedStringWithText:arr[i] withRangText:@"买家3天内无投诉" withColor:RGB(236, 11, 11) withFont:[UIFont systemFontOfSize:12]];
            label.attributedText = atrtabl;
            self.chushouView.frame = CGRectMake(0,self.majixuzhiview.bottom, kScreenW, 50+h0+h1+h2+h3+h4+i*10);
            
            
        }
       
        
    }
    
    
    
    
    
    
}



- (CGFloat)calculateRowHeight:(NSString *)string fontSize:(NSInteger)fontSize

{
    
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:fontSize]};
    
 //  NSDictionary *dic = @{NSFontAttributeName:[UIFont fontWithName:@"PingFang SC" size: 12]};
    
    CGRect rect = [string boundingRectWithSize:CGSizeMake(kScreenW-17*2, MAXFLOAT)/*计算高度要先指定宽度*/ options:NSStringDrawingUsesLineFragmentOrigin |
                   
                   NSStringDrawingUsesFontLeading attributes:dic context:nil];
    
    return rect.size.height;
    
}


    

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
